<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>use id to select element</title>
	<style>
	  section {
		  margin-top: 10px;
		}
	</style>
	<script>
	  //var foo = function(){}
		var foo = 'foo'
	</script>
</head>
<body>
  <section>
	  <p>覆盖失败</p>
	  <div id="window">window</div>
	  <div id="document">document</div>
	</section>
	<section>
	  <p>使用id引用</p>
	  <div id="foo">id: foo</div>
	  <div id="bar">id: bar</div>
		<div id="two-word">id: two-word</div>
	</section>
	<section>
	  <p>使用name引用</p>
		<form action="#" name="form">表单</form>
		<img src="" alt="img" name="img">
	</section>
	<section>
	  <div>可在控制台测试变量</div>
	  <div id="result"></div>
		<div>two-word的引用需要使用: window['two-word']</div>
	</section>
	<script>
	  var bar = 'bar'

		result.textContent = 'foo is ' + foo + ', bar is ' + bar
	</script>
</body>
</html>
